package com.example.activity;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class BlueActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //去掉ActionBar
        ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null){
            actionBar.hide();
        }
        //设置布局
        setContentView(R.layout.blueactivity_layout);
       //获取Button实例
        Button closeBt = findViewById(R.id.close_bt);
        //获取TextView实例
        TextView blue_act_content_tv = findViewById(R.id.blue_act_content_tv);
        //获取intent实例
        Intent intent = getIntent();
        //读取intent的数据给bundle对象
        Bundle bundle = intent.getExtras();
        String msg = bundle.getString("msg");

        User data = (User) bundle.get("data");
        //给TextView设置显示内容
        blue_act_content_tv.setText("姓名："+data.getName()+" , 年龄："+data.getAge()+" , 班级："+data.getClassName()+"  ,消息内容: "+msg);

        //按钮触发事件监听
        closeBt.setOnClickListener((v)->{
            //关闭Activity
            finish();
        });



    }
}
